package com.we823.cms.repository.service.sys;

import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.google.common.collect.Sets;
import com.we823.cms.model.sys.Role;
import com.we823.cms.repository.dao.sys.RoleMapper;
import com.we823.cms.repository.service.AbstractBaseService;
import tk.mybatis.mapper.entity.Example;

@Service
@Scope("prototype")
public class RoleService extends AbstractBaseService<Role, Integer> {

	private RoleMapper roleMapper;
	
	@Autowired
	public RoleService(RoleMapper roleMapper) {
		super(roleMapper);
		this.roleMapper = roleMapper;
	}

	public Set<String> findByRoleIdIn(List<Integer> roleidList) {
		Example example = new Example(Role.class);
		Example.Criteria criteria = example.createCriteria();
		criteria.andIn("roleId", roleidList);
		List<Role> roleModels = roleMapper.selectByExample(example);
		if (roleModels==null) return null;

		Set<String> roleSet = Sets.newHashSet();
		for (Role roleModel : roleModels) {
			roleSet.add(roleModel.getIdentity());
		}
		return roleSet;
	}

}
